<?php
    include('header.php');
    include('sidebar2.php');
    
    $code = $_GET['code'];
    $sec = $_GET['sec'];
    $mem_info = $db->queryUniqueObject("SELECT m_id FROM hs_member WHERE m_seccode LIKE '$code' AND MD5(m_id) LIKE '$sec'");
    
    if($mem_info->m_id==NULL){
        $msg = $status_msg['invalid_code'];
        $class= '';
        $class2= 'x';
    }else{
        $class= 'x';
        $class2= '';
    }
?>
            <div id="main_content" class="register_content">
                <img src="images/register_title.jpg" alt="Order" id="register_title" />
                
                <form name="regis_frm" id="regis_frm" class="display_none<?php echo $class; ?>">
                <input type="hidden" name="m_id" id="m_id" value="<?php echo $mem_info->m_id; ?>" />
                <div class="regis_frm">
                    <span>New Password :</span>
                    <input type="password" name="userPass" id="userPass" /> *
                </div>
                
                <div class="regis_frm">
                    <span>Confirm Password :</span>
                    <input type="password" name="confPass" id="confPass" /> *
                </div>
                </form>
                
                <div class="regis_frm display_none<?php echo $class; ?>">
                    <span>&nbsp;</span>
                    <img src="images/register_submit_bt.jpg" alt="submit" id="register_submit_bt" class="img_link"/>
                    <img src="images/ajax-loader.gif" alt="submit" id="ajax_loader" class="display_none" />
                </div>
                
                <div id="success_msg" class="display_none<?php echo $class2; ?>">
                <?php echo $msg; ?>
                </div>
                
                <div id="success_msg2" class="display_none">
                <?php echo $status_msg['pass_change_success']; ?>
                </div>
            </div>
            <div class="clear">&nbsp;</div>
<?php
    include('footer.php');
?>
<script type="text/javascript" src="js/jquery.validate.min.js"></script>
<script>
    $(function() {
        $("#regis_frm").validate({
            rules: {
                userPass: {
                        required: true,
                        rangelength:[5,15]
		    },
                confPass: {
                        required: true,
                        equalTo: "#userPass"
                }
            },
            messages: {
                userPass: {
                        required: "Please provide a password",
                        rangelength: "Please enter a password, between 5 and 15 characters"
                },
                confPass: {
                        required: "Please confirm your password",
                        equalTo: "Please enter the same password as above"
                }
            }
        });
        
        $('#register_submit_bt').click(function(){
            if($("#regis_frm").valid()){
                $("#register_submit_bt").css('display','none');
                $("#ajax_loader").css('display','block');
                var str = $("#regis_frm").serialize();
                $.post("function/member_forget_pass.php", str ,function(data){
                    if(trim(data)=='success'){
                        $("#regis_frm , .regis_frm").css('display','none');
                        $("#success_msg2").css('display','block');
                        //setInterval("window.location='?page=press_room';",5000);
                    }else{
                        alert(data);
                        $("#register_submit_bt").css('display','block');
                        $("#ajax_loader").css('display','none');
                        $("#email").focus();
                    }
                });
            }
        });
    });
</script>